import numpy as np
import matplotlib.pyplot as plt

from utils import set_chinese
from utils import get_image


# 反色变换函数
def image_revise(input):
    value_max = np.max(input)
    output = value_max - input
    return output


def main():
    gray_img = get_image('./Xarray.jpeg')
    inv_img = image_revise(gray_img)

    set_chinese()
    fig = plt.figure()
    ax1 = fig.add_subplot(121)
    ax1.set_title('原图')
    ax1.imshow(gray_img, cmap='gray', vmin=0, vmax=255)

    ax2 = fig.add_subplot(122)
    ax2.set_title('反色变换后')
    ax2.imshow(inv_img, cmap='gray', vmin=0, vmax=255)

    plt.show()


if __name__ == '__main__':
    main()